#include"myStdio.h"
#include<unistd.h>
#include<stdio.h>

//C++也有对应的文件操作
//进程与被打开文件
//一个文件要被写入或者读取就必须要被打开！
int main()
{
    FILE_* fp = fopen_("log.txt","w");\
    if(fp == NULL)
    {
        return 1;
    }

    const char* msg = "hello fopen";
    int cnt = 10;
    while(1)
    {
    fwrite_(msg,strlen(msg),fp);
    printf("%d\n",cnt);
    cnt--;
    sleep(1);
        if(cnt == 5)fflush_(fp);
        if(cnt == 0)break;
    }
    
    fclose_(fp);
    return 0;
}
